﻿@model SportsStore.Web.Models.CartItem.CartItemsViewModel

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Your cart</h2>
<table width="90%" align="center">
  <thead>
    <tr>
      <th align ="center">Quantity</th>
      <th align ="left">Item</th>
      <th align ="right">Price</th>
      <th align ="right">Subtotal</th>
    </tr>
  </thead>
  <tbody>
    @foreach (var carItem in Model.CartItems)
    {
      <tr>
        <td align="center">@carItem.Quantity</td>
        <td align="left">@carItem.ProductViewModel.Name</td>
        <td align="right">@((carItem.Quantity * carItem.ProductViewModel.Price).ToString("c"))</td>
        <td align="right">@carItem.Quantity</td>
        <td>
          @using (Html.BeginForm("RemoveFromCart", "CartItem"))
          {
            @Html.Hidden("Id", carItem.ProductId)
            <input class="actionButtons" type="submit" value="Remove"/>
          }
        </td>
      </tr>
    }
  </tbody>
  <tfoot>
    <tr>
      <td colspan="3" align="right">Total:</td>
      <td align="right">@Model.CartTotal</td>
    </tr>
  </tfoot>
</table>
<p align="center" class="actionButtons">
  @Html.ActionLink("Continue shopping", "Index", new { Controller = "Product"})
</p>
